Computers include general purpose central processing units (CPUs) that are designed to execute a specific set of system instructions. A group of processors that have similar architecture or design specifications may be considered to be members of the same processor family. Examples of current processor families include the Motorola 680X0 processor family, manufactured by Motorola, Inc. of Phoenix, Ariz.; the Intel 80X86 processor family, manufactured by Intel Corporation of Sunnyvale, Calif.; and the PowerPC processor family, which is manufactured by Motorola, Inc. and used in computers manufactured by Apple Computer, Inc. of Cupertino, Calif. Although a group of processors may be in the same family because of their similar architecture and design considerations, processors may vary widely within a family according to their clock speed and other performance parameters.
Each family of microprocessors executes instructions that are unique to the processor family. The collective set of instructions that a processor or family of processors can execute is known as the processor's instruction set. As an example, the instruction set used by the Intel 80X86 processor family is incompatible with the instruction set used by the PowerPC processor family. The Intel 80X86 instruction set is based on the Complex Instruction Set Computer (CISC) format. The Motorola PowerPC instruction set is based on the Reduced Instruction Set Computer (RISC) format. CISC processors use a large number of instructions, some of which can perform rather complicated functions, but which require generally many clock cycles to execute. RISC processors use a smaller number of available instructions to perform a simpler set of functions that are executed at a much higher rate.
The uniqueness of the processor family among computer systems also typically results in incompatibility among the other elements of hardware architecture of the computer systems. A computer system manufactured with a processor from the Intel 80X86 processor family will have a hardware architecture that is different from the hardware architecture of a computer system manufactured with a processor from the PowerPC processor family. Because of the uniqueness of the processor instruction set and a computer system's hardware architecture, application software programs are typically written to run on a particular computer system running a particular operating system.
Computer manufacturers want to maximize their market share by having more rather than fewer applications run on the microprocessor family associated with the computer manufacturers' product line. To expand the number of operating systems and application programs that can run on a computer system, a field of technology has developed in which a given computer having one type of CPU, called a host, will include an emulator program that allows the host computer to emulate the instructions of an unrelated type of CPU, called a guest. Thus, the host computer will execute an application that will cause one or more host instructions to be called in response to a given guest instruction. Thus the host computer can both run software design for its own hardware architecture and software written for computers having an unrelated hardware architecture. As a more specific example, a computer system manufactured by Apple Computer, for example, may run operating systems and program written for PC-based computer systems. It may also be possible to use an emulator program to operate concurrently on a single CPU multiple incompatible operating systems. In this arrangement, although each operating system is incompatible with the other, an emulator program can host one of the two operating systems, allowing the otherwise incompatible operating systems to run concurrently on the same computer system.
When a guest computer system is emulated on a host computer system, the guest computer system is said to be a virtual machine, as the host computer system exists only as a software representation of the operation of the hardware architecture of the guest computer system. The terms emulator, virtual machine, and processor emulation are sometimes used interchangeably to denote the ability to mimic or emulate the hardware architecture of an entire computer system. As an example, the Virtual PC software created by Connectix Corporation of San Mateo, Calif. emulates an entire computer that includes an Intel 80X86 Pentium processor and various motherboard components and cards. The operation of these components is emulated in the virtual machine that is being run on the host machine. An emulator program executing on the operating system software and hardware architecture of the host computer, such as a computer system having a PowerPC processor, mimics the operation of the entire guest computer system.
The emulator program acts as the interchange between the hardware architecture of the host machine and the instructions transmitted by the software running within the emulated environment. This emulator program may be a host operating system (HOS), which is an operating system running directly on the physical computer hardware. Alternately, the emulated environment might also be a virtual machine monitor (VMM) which is a software layer that runs directly above the hardware and which virtualizes all the resources of the machine by exposing interfaces that are the same as the hardware the VMM is virtualizing (which enables the VMM to go unnoticed by operating system layers running above it). A host operating system and a VMM may run side-by-side on the same physical hardware.
The evolution of the development of the x86-architecture by Intel Corporation (Santa Clara, Calif.) started with a 16-bit processor (x86-16), then extended to a 32-bit processor (x86-32), and is currently being extended to a 64-bit processor (x86-64). The 64-bit x86-architecture which is generically known as the x86-64 architecture, is being developed by Advanced Micro Devices (AMD) of Sunnyvale, Calif., as well as by Intel. For example, the AMD 64-bit product is known commercially as AMD64. A distinction is made, however, between the 64-bit x86-architecture of this discussion and another 64-bit product jointly developed by Hewlett-Packard (Palo Alto, Calif.) and Intel known as IA64. IA64 has a 64-bit instruction set architecture that is implemented in Itanium® processors. Generally, the IA64 architecture has no backward compatibility and, thus, x86-architecture software will not run on the IA64 architecture because of the different instruction set. Consequently, the discussion herein of the 64-bit architecture refers exclusively to the x86-64 architecture not the IA64 architecture.
Providing backward compatibility that allows a virtual machine written for a 32-bit legacy OS to run on a 64-bit OS is important to software manufacturers, as backward compatibility enables a shorter time-to-market for new 32-bit products and extends the use of legacy 32-bit applications. The x86-64 architecture supports several different modes of operation including the operating modes of the traditional 32-bit x86 architecture, which are outlined as follows.
Traditional 32-bit x86 architecture (x86-32):REAL MODEPROTECTED MODE:V86 SUB-MODERING-0, −1, −2, −3 SUB-MODES(Note: As used herein, the terms “mode,” “sub-mode,” and “super-mode” are used to better distinguish the different mode layers of the different architectures; however, as well known and readily appreciated by those of skill in the art, all of these variations are quite often referred to simply as “modes,” without regard for relative structure.)
Generally, REAL MODE is an operating mode that allows the execution of only one program at a time. In REAL MODE, programs can only access 1024K of memory and use a 16-bit data path. PROTECTED MODE provides support for virtual memory and multitasking (running more than one program at a time). PROTECTED MODE programs can access addresses above 1024K and can use a 32-bit data path. REAL MODE is the precursor to PROTECTED MODE, in which each program needs all the memory to run and will not allow the execution of another application at the same time. PROTECTED MODE further includes a RING-0 SUB-MODE, a RING-1 SUB-MODE, a RING-2 SUB-MODE, a RING-3 SUB-MODE, and a V86 SUB-MODE (virtual 8086). (Generally, RING-1 and RING-2 SUB-MODES are not used by current applications.)
RING-0 SUB-MODE refers to the Intel 80286 PROTECTED MODE architecture. RING-0 SUB-MODE is the most privileged level, with access to all system resources. RING-0 SUB-MODE is the most privileged code that is used by the OS and its drivers and that have a high level of trust. RING-3 SUB-MODE also refers to the Intel 80286 PROTECTED MODE architecture. RING-3 SUB-MODE is the least privileged level that is used for code that has a low level of trust and is used by all user applications. V86 SUB-MODE refers to the Intel 80386 PROTECTED MODE architecture, a sub-mode in which the CPU emulates the 8086 REAL MODE addressing, but maintains support for paging and certain access restrictions.
By contrast, the x86-64 architecture supports two primary super-modes, i.e., a LEGACY SUPER-MODE and a LONG SUPER-MODE, which are outlined as follows.
Expanded 62-bit x86 architecture (x86-64):LEGACY SUPER-MODEREAL MODEPROTECTED MODE:V86 SUB-MODERING-0, −1, −2, −3 SUB-MODESLONG SUPER-MODECOMPATIBILITY MODERING-3 SUB-MODENATIVE LONG MODE
The x86-64 architecture LEGACY SUPER-MODE includes all the modes and sub-modes of the traditional 32-bit x86 architecture, i.e., REAL MODE, PROTECTED MODE, etc. Additionally, the x86-64 architecture LONG SUPER-MODE includes a NATIVE LONG MODE and a COMPATIBILITY MODE. NATIVE LONG MODE allows for running 64-bit ring-0 code. COMPATIBILITY MODE allows 32-bit ring-3 applications to run on top of an OS that is running 64-bit NATIVE LONG MODE, i.e., a mixed environment. Therefore, 32-bit application can run the COMPATIBILITY MODE while a 64-bit application is simultaneously running in NATIVE LONG MODE.
However, a problem exists in that COMPATIBILITY MODE of the x86-64 architecture only supports the RING-3 SUB-MODE. COMPATIBILITY MODE does not support V86 SUB-MODE or RING-0 SUB-MODE, and at least one (if not both) of these are required for a 32-bit virtual machine (VM) to fully and seamlessly emulate/virtualize a 32-bit hardware environment. Therefore, what is needed are ways for virtual machines that rely on the traditional 32-bit modes, i.e., REAL MODE and PROTECTED MODE (V86 SUB-MODE, RING-0 SUB-MODE, and RING-3 SUB-MODE), to run alongside other applications on a 64-bit processor but still be able to execute ring-0 code as well as access the features of the V86 SUB-MODE.
One solution is for a virtual machine environment operating in the x86-64 architecture to be able to freely transition back and forth between LONG SUPER-MODE and LEGACY SUPER-MODE to, for example, transition back and forth between a guest running a 32-bit OS and the host running a 64-bit OS on a 64-bit processor. However, the implementation of the AMD64 machine, for example, did not anticipate a transition back and forth between LONG SUPER-MODE and LEGACY SUPER-MODE; instead, the implementation of the AMD64 machine assumes that the machine starts in LEGACY SUPER-MODE, makes a single transition to LONG SUPER-MODE when the OS loads, and never returns to LEGACY SUPER-MODE. What is needed is a method of switching back and forth between LONG SUPER-MODE and LEGACY SUPER-MODE in the x86-64 architecture.